﻿using System.Configuration;

namespace Borg.Config
{
    public class PathElementCollection : ConfigurationElementCollection
    {
        public PathElement this[int index]
        {
            get { return (PathElement)BaseGet(index); }
        }

        protected override ConfigurationElement CreateNewElement()
        {
            return new PathElement();
        }

        protected override object GetElementKey(ConfigurationElement element)
        {
            return ((PathElement)element).Path;
        }

        public override bool IsReadOnly()
        {
            return false;
        }

        public void Add(string path)
        {
            BaseAdd(new PathElement(path));
        }

        public void Remove(string path)
        {
            BaseRemove(path);
        }

        public bool Contains(string path)
        {
            return BaseGet(path) != null;
        }

        public void Clear()
        {
            BaseClear();
        }
    }
}
